package com.example.mapper;

import com.example.domain.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.edit.NewPassword;
import com.example.domain.paging.PageHelper;
import com.example.domain.query.UserQuery;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-04-17
 */
@Component
public interface UserMapper extends BaseMapper<User> {
    //增加
    @Insert("insert into user values(null,#{username},#{phone},#{password},#{role},#{address},1)")
    boolean save(User user);

    //查询所有
    @Select("select * from user where status=1")
    List<User> list();

    //删除
    @Update("update user set status=0 where uid=#{uid} ")
    boolean delete(Integer id);

    @Update("update user set password=#{newPassword} where uid=#{uid}")
    int editPassword(NewPassword newPassword);

    List<User> findAll(PageHelper pageHelper);

}
